const tree = {
  value: 'a',
  children: [{
    value: 'b',
    children: [{
      value: 'd',
      children: []
    },{
      value: 'e',
      children: []
    }]
  },{
    value: 'c',
    children: [{
      value: 'f',
      children: []
    },{
      value: 'g',
      children: []
    }]
  }]
}

const bfs = (node) => {
  const list = [node]
  while(list.length > 0){
    const element = list.shift()
    console.log(element.value)
    element.children.forEach(child => {
      list.push(child)
    });
  }
}

bfs(tree)
